package com.rsscollector.model;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.rsscollector.model.vo.User;
import com.rsscollector.util.PersistenceUtil;

public class UserFacade {
	
    public static User getUserByEmail(String email) {
        EntityManager em = PersistenceUtil.getEntityManager();
        Query q = em.createQuery("SELECT u FROM User u WHERE u.email = ?1");
        q.setParameter(1, email);
        List list = q.getResultList();
        User result = (User) (list.size() > 0 ? list.get(0) : null);
        return result;
    }    
    
}
